<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>LDAP群组管理</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <link href="__PUBLIC__/plugins/bootstrap.min.css" rel="stylesheet">
        <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css"  media="all">        
        <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all" />
        <link href="__PUBLIC__/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">        
        <link rel="stylesheet" href="__CSS__/admin.css"  media="all">
    </head>
    <body style="padding:10px;">
        <div class="tplay-body-div">
            <div class="layui-tab">
                <ul class="layui-tab-title">
                    <li class="layui-this">群组管理</li>
                    <li><a href="{:url('admin/ldapgroup/publish')}" class="a_menu">新增群组</a></li>
                </ul>
            </div>
            <table id="dataTables" class="layui-table display">
                <colgroup>
                    <col width="50">
                    <col width="150">
                    <col width="200">
                    <col width="100">
                    <col width="100">
                    <col width="100">
                </colgroup>
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>组名</th>
                        <th>组描述</th>
                        <th>成员数量</th>
                        <th>成员</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    {volist name="groupList" id="vo"}
                    <tr>
                        <td>{$vo.id}</td>
                        <td>{$vo.cn}</td>
                        <td>{$vo.description}</td>
                        <td>{notempty name="$vo.memberuid.count"}{$vo.memberuid.count}{/notempty}</td>
                        <td><a href="{:url('admin/ldapgroup/groupUsers',['id'=>$vo.cn])}" class="preview" style="margin-right: 0;font-size:12px;">查看组成员</a></td>
                        <td class="operation-menu">
                            <div class="layui-btn-group">
                                <a href="{:url('ldapgroup/publish',['id'=>$vo.cn])}" class="layui-btn layui-btn-xs a_menu layui-btn-primary" id="{$vo.cn}" style="margin-right: 0;font-size:12px;"><i class="layui-icon"></i></a>
                                <a class="layui-btn layui-btn-xs layui-btn-primary delete" id="{$vo.cn}" style="margin-right: 0;font-size:12px;"><i class="layui-icon"></i></a>
                            </div>
                        </td>
                    </tr>           
                    {/volist}
                </tbody>
            </table>

            {include file="public/foot"}
            <script type="text/javascript" src="__PUBLIC__/plugins/dataTables/jquery.dataTables.js"></script>
            <script type="text/javascript" src="__PUBLIC__/plugins/dataTables/dataTables.bootstrap.js"></script>
            <script type="text/javascript">

                $('.delete').click(function () {
                    var id = $(this).attr('id');
                    layer.confirm('确定要删除?', function (index) {
                        $.ajax({
                            url: "{:url('admin/ldapgroup/delete')}",
                            data: {id: id},
                            success: function (res) {
                                layer.msg(res.msg);
                                if (res.code == 1) {
                                    setTimeout(function () {
                                        location.href = res.url;
                                    }, 1500)
                                }
                            }
                        })
                    })
                })

                layui.use('layer', function () {
                    var layer = layui.layer;
                    $('#dataTables').dataTable();
                    $(document).on('click', '.preview', function () {
                        var url = $(this).attr('href');
                        var index = layer.open({
                            title: "查看组成员",
                            type: 2,
                            content: url,
                            area: ['800px', '600px']
                        });
                        return false;
                    })
                });
            </script>
        </div>
    </body>
</html>
